package netTest;

import java.io.IOException;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;

/*
服务器socket
 */
public class Server {
    public static void main(String[] args) throws IOException {
        //创建一个ServerSocket，用于监听客户端Socket的连接请求
        ServerSocket serverSocket = new ServerSocket(30000);
        while(true) {
            //每当接收到客户端的请求时，服务器也对应生成一个Socket
            Socket socket = serverSocket.accept();
            PrintStream printStream = new PrintStream(socket.getOutputStream());
            printStream.println("您好，您收到了服务器的祝福！");
            printStream.close();
            socket.close();

        }
    }
}
